package com.xd.user.api.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.xd.common.base.BaseModel;
import com.xd.common.constant.CommonConstant;
import com.xd.common.vo.Validity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;

/**
 * @author Exrick
 */
@Data
@Entity
@Accessors(chain = true)
@Table(name = "xd_dict_data")
@TableName("xd_dict_data")
@org.hibernate.annotations.Table(appliesTo = "xd_dict_data", comment = "字典数据")
@ApiModel(value = "字典数据")
public class DictData extends BaseModel<DictData> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "数据名称")
    @Column(nullable = false, columnDefinition = "varchar(100)  default '' comment '数据名称'")
    @NotBlank(message = "数据名称不可为空", groups = {Validity.Add.class, Validity.Upload.class})
    @Size(message = "数据名称字数不可大于100", groups = {Validity.Add.class, Validity.Upload.class})
    private String title;

    @ApiModelProperty(value = "数据值")
    @Column(nullable = false, columnDefinition = "varchar(100)  default '' comment '数据值'")
    @NotBlank(message = "数据值不可为空", groups = {Validity.Add.class, Validity.Upload.class})
    @Size(message = "数据值字数不可大于100", groups = {Validity.Add.class, Validity.Upload.class})
    private String value;

    @ApiModelProperty(value = "排序值")
    @Column(precision = 10, scale = 2, columnDefinition = "decimal default 0 comment '排序值 '")
    @NotNull(message = "排序值不可为空", groups = {Validity.Add.class, Validity.Upload.class})
    @Digits(message = "排序值不符合规范", groups = {Validity.Add.class, Validity.Upload.class}, integer = 3, fraction = 2)
    private BigDecimal sortOrder;

    @ApiModelProperty(value = "是否启用 0启用 -1禁用")
    @Column(nullable = false, columnDefinition = "tinyint default 0 comment '是否启用 0启用 -1禁用'")
    private Integer status = CommonConstant.STATUS_NORMAL;


    @ApiModelProperty(value = "所属字典")
    @Column(nullable = false, columnDefinition = "varchar(255) default '' comment '所属字典 '")
    @NotBlank(message = "所属字典不可为空", groups = {Validity.Add.class, Validity.Upload.class})
    private String dictId;
}
